<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <title>Title</title>
</head>

<body>
    <script>
        let num = 0;
        //false = 0
        console.log(num == false);

        // let num2 = 10;
        // console.log(num2 == true);

        let hd = "0";

        //Number(array)  = 0
        let array = [];
        console.log(array == false);

        let array2 = [1];
        console.log(array2 == true);

        let array3 = [1, 2];
        //array3 是 Nan

        //引用类型为真

        //总结：数值类型，除了000OO000 O都为真，字符串类型，除了空字符串都为真，数组对象都为真

        let number = 0;
        console.log(typeof number);

        // number = !number;
        // console.log(typeof number);
        // console.log(number)

        //先转换为boolean类型，但是此时取反了，然后再取反即可拿到正确boolean值
        number = !!number;
        console.log(typeof number);
        console.log(number)

        //通过 ！！特性，可以快速判断字符串是否为空 ，当然判断为空 可以直接！取反，空字符串是false
        let str = "aaa";
        if (!!str) {
            console.log("str 不为空");
        }
    </script>
</body>

</html>